﻿package com.tvein.sanguo.swc.crowd
{
	//flash
	import flash.display.MovieClip;
	//A3D
	//custom
	import com.tvein.sanguo.swc.crowd.Human;
//
	public class HumanFrame extends MovieClip
	{
		public static const NAME:String = "HumanFrame";
		
		public function HumanFrame()
		{
			
		}
		
		public function Clear():void
		{
			for (var i:int = this.numChildren - 1; i >= 0; i--)
			{
				this.removeChildAt(0); 
			}
		}
		
		public function Add(roleID:String, roleName:String, roleFace:int, roleCMD:Object, gameConfig:Array):void
		{
			var newHuman:Human = new Human(roleID, roleName, roleFace, roleCMD, gameConfig);
			newHuman.name = roleID;
			newHuman.y = this.numChildren * 125;
			
			this.addChild(newHuman);
		}
		
		public function Delete(roleID:String):void
		{
			var isMoved:Boolean = false;
			
			for (var i:int = 0; i < this.numChildren; i++)
			{
				if (this.getChildAt(i).name == roleID)
				{
					this.removeChild(this.getChildAt(i));
					isMoved = true;
					i--;
				}
				else if (isMoved)
				{
					this.getChildAt(i).y = this.getChildAt(i).y - 125;
				}
			}
		}
	}
}